#include <stdio.h>

void main_munu()
{
    char a[7][90] = {"munu","frappe","Milkshake","tea with milk","street food","mixed ingredients","Flavoring agent"};
    int i;
    printf ("%s\n",a[0]);
    for ( i = 1; i < 7; i++)
    {
        printf ("\t%d.%s\n",i,a[i]);
    }
    printf ("\t0.end of older\n");
}

void menu_frappe()
{
    char a[4][90] = {"Ice Black Tea","Ice green tea","Mocha ice","Matcha sand ice"};
    printf ("Please select specific dishes\n");
    for (int i = 0; i < 4; i++)
    {
        printf ("\t\t%d.%s\n",i+1,a[i]);
    }
    printf ("\t\t0.Return to the upper menu\n");
}

void menu_Milkshake()
{
    char a[4][90] = {"Strawberry Milkshake","Mango milkshake","Blueberry milkshake","Banana milkshake"};
    printf ("Please select specific dishes\n");
    for (int i = 0; i < 4; i++)
    {
        printf ("\t\t%d.%s\n",i+1,a[i]);
    }
    printf ("\t\t0.Renturn to the uppper menu\n");
}

void menu_tea_with_milk()
{
    char a[4][90] = {"pure milk","Strawberry Milk Tea","Bubble Tea","Watermelon milk tea"};
    printf ("Please select specific dishes\n");
    for (int i = 0; i < 4; i++)
    {
        printf ("\t\t%d.%s\n",i+1,a[i]);
    }
    printf ("\t\t0.Return to the upper menu\n");
}

void menu_street_food()
{
    char a[4][90] = {"French fries", "chicken rice flower", "spicy chicken wings", "hamburger"};
    printf ("Please selsct specific dishes\n");
    for (int i = 0; i < 4; i++)
    {
        printf ("\t\t%d.%s\n",i+1,a[i]);  
    }
    printf ("\t\t0.Return to the upper menu\n");
}

void menu_mixed_ingredients()
{
    char a[4][90] = {"Pearl", "coconut", "taro balls", "red beans"};
    printf ("Please selsct specific dishes\n");
    for (int i = 0; i < 4; i++)
    {
        printf ("\t\t%d.%s\n",i+1,a[i]);  
    }
    printf ("\t\t0.Return to the upper menu\n");
}

void menu_Flavoring_agent()
{
    char a[4][90] = {"White sugar", "ketchup", "chili sauce", "salad dressing"};
    printf ("Please selsct specific dishes\n");
    for (int i = 0; i < 4; i++)
    {
        printf ("\t\t%d.%s\n",i+1,a[i]);  
    }
    printf ("\t\t0.Return to the upper menu\n");
}

int main (int argc, const char * argv[])
{
    printf ("********L Milk Tea Shop*********\n");
    printf ("****Welcome to the L Milk Tea Shop****\n");
    int M;
    int n;
    int x[6][4] = {0};
    int price1[6][4] = {0};
    int price[6][4] = {{22,22,35,35},{35,35,35,35},{22,35,22,35},{15,20,20,20},{1,2,1,3},{0,0,0,0}};
    int total = 0;
    char name[6][4][90] = {{"Ice Black Tea","Ice green tea","Mocha ice","Matcha sand ice"},{"Strawberry Milkshake","Mango milkshake","Blueberry milkshake","Banana milkshake"},{"pure milk","Strawberry Milk Tea","Bubble Tea","Watermelon milk tea"},{"French fries", "chicken rice flower", "spicy chicken wings", "hamburger"},{"Pearl", "coconut", "taro balls", "red beans"},{"White sugar", "ketchup", "chili sauce", "salad dressing"}};
    while(1)
    {
        main_munu();
        scanf ("%d",&M);
        if (M == 0)
        {
            break;
        }
        switch (M)
        {
            case 1:
            {
                menu_frappe();
                while(1)
                {
                    scanf ("%d",&n);
                    if (n == 0)
                    {
                        break;
                    }
                    price1[0][n-1] += price[0][n-1];
                    x[0][n-1] ++;
                }
            }
            if (n == 0)
                break;
            case 2:
            {
                menu_Milkshake();
                while(1)
                {
                    scanf("%d",&n);
                    if (n == 0)
                    {
                        break;
                    }
                    price1[1][n-1] = price[1][n-1];
                    x[1][n-1]++;
                }
            }
            if (n == 0)
                break;
            case 3:
            {
                menu_tea_with_milk();
                while(1)
                {
                    scanf ("%d",&n);
                    if (n == 0)
                    {
                        break;
                    }
                    price1[2][n-1] += price[2][n-1];
                    x[2][n-1]++;
                }
            }
            if (n == 0)
                break;
            case 4:
            {
                menu_street_food();
                while(1)
                {
                    scanf ("%d",&n);
                    if(n == 0)
                    {
                        break;
                    }
                    price1[3][n-1] += price[3][n-1];
                    x[3][n-1]++;
                }
            }
            if ( n == 0)
                break;
            case 5:
            {
                menu_mixed_ingredients();
                while(1)
                {
                    scanf ("%d",&n);
                    if (n == 0)
                    {
                        break;
                    }
                    price1[4][n-1] += price[4][n-1];
                    x[4][n-1]++;
                }
            }
            if (n == 0)
                break;
            case 6:
            {
                menu_Flavoring_agent();
                while(1)
                {
                    scanf ("%d",&n);
                    if (n == 0)
                    {
                        break;
                    }
                    price1[5][n-1] += price[5][n-1];
                    x[5][n-1]++;
                }
            }
            if (n == 0)
                break;
        }
    }

    printf ("dish name\t\t\t\tunit price(element)\t\t\tnumber\t\ttotal price(element)\n--------------------------------------\n");
    for (int i = 0; i < 6; i++)
    {
        for (int j = 0; j < 4; j++)
        {
            if (price1[i][j] != 0)
            {
                printf("%s\t\t%3d\t\t%3d\t%3d\n",name[i][j],price[i][j],x[i][j],price1[i][j]);
                total += price1[i][j];
            }
        }
    }
    printf ("total price : \t\t\t\t\t%3d\n",total);
    if (total >= 100 && total < 150)
    {
        total = total - 5;
        printf ("total: \t\t\t\t\t\t\t%3d\n",total);
    }
    if (total >= 150)
    {
        total = total - 10;
        printf ("total: \t\t\t\t\t\t\t%3d\n",total);
    }
    printf ("I wish you a pleasant meal and look forward to your next visit!\n");
    return 0;
}